/*
 * traininfo_dao.h
 *
 *  Created on: 2013-2-14
 *      Author: panqiuhui
 */

#ifndef TRAININFO_DAO_H_
#define TRAININFO_DAO_H_
#include <stdbool.h>
#include "db_connection.h"
#include "../common_struct/traininfo.h"
#include "../common_struct/stationlist.h"
#include "../common_struct/start_end_stationlist.h"
#include "../common_struct/station_pass_trainlist.h"

//查询车站的车票起售时间，成功返回true，失败返回false
bool query_start_sale_time(struct stationinfo *station);

//查询某个车次经过的车站信息，成功返回true并将结果添加到stationlist中，失败返回false
bool search_train_number(const struct train_number_request *request,
		StationList *stationlist);

//查询发到站信息，成功返回true并将结果添加到start_end_stationlist中，失败返回false
bool search_start_end_station(
		const struct train_start_end_station_request *request,
		StartEndStationList *start_end_stationlist);

//查询车站经过车次信息，成功返回true并将结果添加到station_pass_trainlist中，失败返回false
bool search_station_pass_train(const struct station_pass_train_request *request,
		StationPassTrainList *station_pass_trainlist);

//查询某个车次的基本信息，成功返回true并将结果添加到traininfo中，失败返回false
bool get_traininfo(const char *trainID, struct traininfo *train);

//查询某个车站的基本信息，成功返回true并将结果添加到stationinfo中，失败返回false
bool get_stationinfo(const char *stationname, struct stationinfo *station);

//检查一个车次的始发站和终到站是否符合要求
bool check_depart_arrive_station(int passStationType,
		const struct traininfo *train, const char *startStationCity,
		const char *endStationCity);

//检查一个车次的类型是否符合要求
bool check_train_type(int trainType, const char *trainID);

//查询某个车次的两个车站的发时、到时以及历时
bool get_start_end_consume_timeinfo(const char *trainID,
		const char *startStation, const char *endStation,
		struct stations_timeinfo *timeinfo);

#endif /* TRAININFO_DAO_H_ */
